// The addElement() function is simple if you understand its arguments. 
// The way it works is by appending a new child element to a parent element. 
// The parent element is specified using the parentId argument. 
// The type of element to be created is specified using the elementTag argument. 
// The new elements ID is specified using ths elementId argument. 
// Lastly, the innerHTML of the new element is specified using the html argument. 

function addElement(parentId, elementTag, elementId, html) {
    // Adds an element to the document
    var p = document.getElementById(parentId),
        newElement = document.createElement(elementTag);
    newElement.setAttribute('id', elementId);
    newElement.innerHTML = html;
    p.appendChild(newElement);
}

// Removing an element is much easier, as it only requires the elements ID. 
function removeElement(elementId) {
    // Removes an element from the document
    var element = document.getElementById(elementId);
    element.parentNode.removeChild(element);
}
